/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.manager;

import br.com.foxline.clinicplus.entity.Customer;
import br.com.foxline.clinicplus.service.CustomerService;
import br.com.foxline.clinicplus.service.DiaryService;
import br.com.foxline.clinicplus.service.RecordsService;
import br.com.foxline.clinicplus.util.Caracter;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author roniere
 */

@ManagedBean
@ViewScoped
public class ManagerDuplicado implements Serializable {

    @EJB
    private CustomerService customerService;
    
    @EJB
    private RecordsService recordsService;
    
    @EJB
    private DiaryService  diaryService;
    
    private Customer customer;
    
    private List<Customer> customers;
    
    @PostConstruct
    public void init(){
        customer = new Customer();
        customers = new ArrayList<Customer>();
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public List<Customer> getCustomers() {
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }
    
    public void searchCustomer() {
        customer.setCpf(Caracter.removecaracter(customer.getCpf()));
        customers = customerService.findCustomer(customer);
    }
    
    public int qtdAtendimento(Long id){
        Customer c = new Customer();
        c.setId(id);
        return diaryService.findDiaryCustomer(c).size();
    }
    public int qtdRecords(Long id){
        Customer c = new Customer();
        c.setId(id);
        return recordsService.getHistoryRecords(c).size();
    }
    
    
}
